<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateActivityPrizes extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        $sql = <<<SQL
        create table dx_activity_prizes
        (
            id int unsigned not null auto_increment
                primary key,
            title varchar(255) not null,
            img_url varchar(255) not null,
            sort int default 0,
            type smallint default 0 comment '奖品类型;1实体产品,0虚拟产品',
            probability int default 0 comment '中奖概率',
            create_time timestamp null default null,
            update_time timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
        )comment '奖品';
SQL;
        if (!DB::statement($sql)) {
            throw new \Exception("failed on execute SQL: [{$sql}]");
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        throw new \Exception('downgrade is forbidden');
    }
}
